﻿<Window x:Class="YSCommander.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="YS Commander" Height="695.486" Width="804.364" 
        Closing="OnClosing" Loaded="Window_Loaded" Icon="/YSCommander;component/YSCommander.ico" MinHeight="500">

    <Window.Resources>
        <Style TargetType="Button">
            <Setter Property="Margin" Value="5"/>
            <Setter Property="Height" Value="23"/>
            <Setter Property="Width" Value="80"/>
        </Style>
    </Window.Resources>

    <DockPanel>
        <Menu DockPanel.Dock="Top">
            <MenuItem Header="Tools">
                <MenuItem Name="menuClearWorkFolder"  Header="Clear work folder" Click="menuClearWorkFolder_Click" />
            </MenuItem>
            <MenuItem Header="Help">
                <MenuItem Name="menuAbout" Header="About" Click="menuAbout_Click"/>
            </MenuItem>
        </Menu>
        <Border BorderThickness="2" BorderBrush="#FF828790" Margin="5" >
            <Grid Margin="5" ShowGridLines="False">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="1.2*" MinWidth="260" />
                    <ColumnDefinition Width="auto" />
                    <ColumnDefinition Width="2*" />
                </Grid.ColumnDefinitions>

                <DockPanel Grid.Column="0">
                    <Label Height="28" HorizontalAlignment="Left" DockPanel.Dock="Top" Target="{Binding ElementName=sectionList}">_Sections:</Label>

                    <StackPanel Height="Auto" HorizontalAlignment="Center" DockPanel.Dock="Bottom" Orientation="Horizontal">
                        <Button Name="buttonAddSection" Click="buttonAddSection_Click">Add</Button>
                        <Button Name="buttonEditSection" Click="buttonEditSection_Click">Edit</Button>
                        <Button Name="buttonDeleteSection" Click="buttonDeleteSection_Click">Delete</Button>
                    </StackPanel>

                    <ListBox Name="sectionList" Margin="5" DataContext="{Binding}"
                 DisplayMemberPath="SectionName"
                 IsSynchronizedWithCurrentItem="True" SelectionChanged="sectionList_SelectionChanged" />

                </DockPanel>

                <GridSplitter Grid.Column="1" HorizontalAlignment="Center" Width="5" />

                <Grid Grid.Column="2">

                    <Grid.RowDefinitions>
                        <!-- 0 Label programs-->
                        <RowDefinition Height="auto"/>

                        <!-- 1 Program list-->
                        <RowDefinition Height="1*"/>

                        <!-- 2 Label Details-->
                        <RowDefinition Height="auto"/>

                        <!-- 3 Details -->
                        <RowDefinition Height="2*"/>

                        <!-- 4 Buttons -->
                        <RowDefinition Height="auto"/>
                    </Grid.RowDefinitions>

                    <Label Grid.Row="0" Target="{Binding ElementName=programList}">_Programs:</Label>

                    <ListBox Grid.Row="1" Name="programList" Margin="15,5,5,5"
                     DataContext="{Binding}"
                 DisplayMemberPath="ProgramName"
                 IsSynchronizedWithCurrentItem="True" SelectionChanged="programList_SelectionChanged" MouseDoubleClick="programList_MouseDoubleClick" AllowDrop="True" DragOver="programList_DragOver" DragLeave="programList_DragLeave" Drop="programList_Drop" />

                    <Label Grid.Row="2">Details:</Label>

                    <Grid Grid.Row="3"  Name="gridProgram">
                        <Grid.RowDefinitions>
                            <!-- 0 Details -->
                            <RowDefinition Height="auto"/>

                            <!-- 1 Label Script -->
                            <RowDefinition Height="auto"/>

                            <!-- 2 Script -->
                            <RowDefinition Height="*" />
                        </Grid.RowDefinitions>

                        <Grid Grid.Row="0" Margin="10">
                            <Grid.RowDefinitions>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>

                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="auto"/>
                                <ColumnDefinition/>
                            </Grid.ColumnDefinitions>

                            <Label Grid.Row="0" Grid.Column="0" Target="{Binding ElementName=textBoxProgramName}">_Name:</Label>
                            <TextBox Grid.Row="0" Grid.Column="1" Margin="5" 
                             Text="{Binding ProgramName}" IsEnabled="False" ToolTip="Program or script name in the list." />

                            <Label Grid.Row="1" Grid.Column="0" Target="{Binding ElementName=textBoxProgramLocation}">Program _location:</Label>

                            <Grid Grid.Row="1" Grid.Column="1">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="auto"/>
                                </Grid.ColumnDefinitions>
                                <TextBox Grid.Column="0" Name="textBoxProgramLocation" Margin="5"
                                     Text="{Binding Location}" 
                                     TextChanged="textBoxProgramLocation_TextChanged" ToolTip="Full path to the program." />
                                <Button Grid.Column="1" Name="buttonBrowseLocation" Width="20" 
                                        Click="buttonBrowseLocation_Click" ToolTip="Opens dialog to choose folder.">...</Button>
                            </Grid>

                            <Label Grid.Row="2" Grid.Column="0" Target="{Binding ElementName=textBoxProgramStartFolder}">Start _folder:</Label>
                            <Grid Grid.Row="2" Grid.Column="1">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="auto"/>
                                </Grid.ColumnDefinitions>
                                <TextBox Grid.Column="0" Name="textBoxProgramStartFolder" Margin="5" 
                                    Text="{Binding StartFolder}" ToolTip="Start folder. May be empty." />
                                <Button Grid.Column="1" Name="buttonBrowseStartFolder" Width="20" Click="buttonBrowseStartFolder_Click" ToolTip="Opens dialog to choose file.">...</Button>
                            </Grid>

                            <Label Grid.Row="3" Grid.Column="0" Target="{Binding ElementName=textBoxParameters}">P_arameters:</Label>
                            <TextBox Grid.Row="3" Grid.Column="1" Margin="5" 
                             Text="{Binding Parameters}" ToolTip="Command line parameters. May be empty." />

                            <Label Grid.Row="4" Grid.Column="0" Target="{Binding ElementName=checkBoxOpenWindow}">Open _window:</Label>
                            <CheckBox Grid.Row="4" Grid.Column="1" Margin="5" IsChecked="{Binding IsOpenWindow}" ToolTip="Set execution window mode as opened or hided." />
                        </Grid>

                        <Label Grid.Row="1" Target="{Binding ElementName=textBoxScript}">S_cript:</Label>

                        <TextBox Grid.Row="2" Name="textBoxScript" Margin="15,5,5,5"
                         Text="{Binding Script}" AcceptsReturn="True" 
                                 VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto"
                                 TextChanged="textBoxScript_TextChanged"/>

                    </Grid>

                    <StackPanel Grid.Row="4" Orientation="Horizontal" HorizontalAlignment="Center">
                        <Button Name="buttonAddProgram" Click="buttonAddProgram_Click" ToolTip="Adds new program into current section.">Add program</Button>
                        <Button Name="buttonAddScript" Click="buttonAddScript_Click" ToolTip="Adds new script into current section.">Add script</Button>
                        <Button Name="buttonCopyProgram" Click="buttonCopyProgram_Click" ToolTip="Copyies the current program or script with new name.">Copy</Button>
                        <Button Name="buttonDeleteProgram" Click="buttonDeleteProgram_Click" ToolTip="Deletes the current program or script.">Delete</Button>
                        <Button Name="buttonExecuteProgram" Click="buttonExecuteProgram_Click" ToolTip="Executes the current program or script.">Execute</Button>
                    </StackPanel>

                </Grid>

            </Grid>
        </Border>

    </DockPanel>
</Window>
